#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define mod 998244353
#define inf 0x3f3f3f3f
#define N 200010
struct un{
    int d,v,a;
}ca[N];
int t,n,m,L,V,ans,p[N],tot;
struct node{
    int l,r;
}b[N];
int s[N*5];
int count(int l,int r){
    return s[r]-s[l-1];
}
vector<int>ed[N];
void clear(){
    tot=0;
    memset(s,0,(L+1)*sizeof(int));
    return;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&t);
    while(t--){
        clear();
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        for(int i=1;i<=n;++i){
            int d,v,a;
            scanf("%lld %lld %lld",&d,&v,&a);
            ca[i]=un{d,v,a};
        }
        for(int i=1;i<=m;++i){
            scanf("%lld",&p[i]);
            s[p[i]]=1;
        }
        for(int i=1;i<=L;++i)s[i]+=s[i-1];
        for(int i=1;i<=n;++i){
            int d=ca[i].d,v=ca[i].v,a=ca[i].a;
            if(a==0){
                if(v>V&&count(d,L)){
                    b[++tot]=node{d,L};
                }
            }
            if(a>0){
                int lim=(V*V-v*v)/(2*a)+d;
                while((lim-d)*(2*a)+v*v<=V*V)++lim;
                if(lim>L)continue;
                if(v>V)lim=d;
                if(count(lim,L)){
                    b[++tot]=node{lim,L};
                }
            }
            if(a<0){
                if(v<V)continue;
                int lim=(v*v-V*V)/(-2*a)+d;
                if(lim<d)continue;
                while((lim-d)*(-2*a)>=v*v-V*V)--lim;
                if(lim<d)continue;
                if(lim>L)lim=L;
                if(count(d,lim)){
                    b[++tot]=node{d,lim};
                }
            }
        }
        printf("%lld ",tot);
        for(int i=1;i<=tot;++i){
            b[i].l=lower_bound(p+1,p+m+1,b[i].l)-p;
            b[i].r=upper_bound(p+1,p+m+1,b[i].r)-p-1;
            ed[b[i].r].push_back(b[i].l);
        }
        int las=0,ans=0;
        for(int i=1;i<=m;++i){
            for(int j=0;j<ed[i].size();++j){
                if(las<ed[i][j]){
                    ++ans;las=i;break;
                }
            }
        }
        printf("%lld\n",m-ans);
        for(int i=1;i<=tot;++i){
            ed[b[i].r].clear();
        }
    }
    return 0;
}